<template>
  <div :style="{height:height,width:width}" />
</template>

<script>
import * as echarts from 'echarts';

export default {
  props: {
    width: {
      type: String,
      default: '95%'
    },
    height: {
      type: String,
      default: '95%'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
      window.addEventListener('resize', this.chart.resize());
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'dark')

      this.chart.setOption({})
    }
  }
}
</script>
<style scoped>
.chartcss {
    position: absolute;
    left: 30px;
    /* top: 10px; */
    width: 100%;
    height: 100%;
}
</style>
